home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 175 (1991-09-10)(Manewaldt, A.)(DE)(PD).zip / Taifun 175 (1991-09-10)(Manewaldt, A.)(DE)(PD).adf / Term / Source.LZH / termInit.c < prev    next >
C/C++ Source or Header  |  1991-07-26  |  28KB  |  1,344 lines

  1. /* $Revision Header * Header built automatically - do not edit! *************
  2.  *
  3.  *    (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
  4.  *
  5.  *    Name .....: TermInit.c
  6.  *    Created ..: Monday 21-Jan-91 20:12
  7.  *    Revision .: 0
  8.  *
  9.  *    Date            Author          Comment
  10.  *    =========       ========        ====================
  11.  *    21-Jan-91       Olsen           Created this file!
  12.  *
  13.  * $Revision Header ********************************************************/
  14.  
  15. #include "TermGlobal.h"
  16.  
  17.     /* Screen title. */
  18.  
  19. STATIC UBYTE ScreenTitle[80];
  20.  
  21.     /* A couple of private strings which are to `impersonate' the
  22.      * control sequences associated with the four function keys.
  23.      */
  24.  
  25. STATIC UBYTE *FunctionKeyCodes[4] =
  26. {
  27.     "\\eOP",
  28.     "\\eOQ",
  29.     "\\eOR",
  30.     "\\eOS"
  31. };
  32.  
  33.     /* Debug data, do not change! */
  34.  
  35. #ifndef DONT_DEBUG
  36.  
  37. BPTR    DebugConsole,DebugFile;
  38. UBYTE    DebugFileName[256];
  39. BYTE    DebugWindow;
  40.  
  41. VOID
  42. DInit()
  43. {
  44.     if(DebugWindow)
  45.         DebugConsole = Open("CON:/11//100/term Debug Console",MODE_NEWFILE);
  46.  
  47.     if(DebugFileName[0])
  48.     {
  49.         if(DebugFile = Open(DebugFileName,MODE_READWRITE))
  50.         {
  51.             if(Seek(DebugFile,0,OFFSET_END) == -1)
  52.             {
  53.                 Close(DebugFile);
  54.  
  55.                 DebugFile = NULL;
  56.             }
  57.         }
  58.     }
  59. }
  60.  
  61. VOID
  62. DExit()
  63. {
  64.     if(DebugConsole)
  65.         Close(DebugConsole);
  66.  
  67.     DebugConsole = NULL;
  68.  
  69.     if(DebugFile)
  70.         Close(DebugFile);
  71.  
  72.     DebugFile = NULL;
  73. }
  74.  
  75. VOID
  76. DPrintf(UBYTE *String,...)
  77. {
  78.     if(DebugConsole || DebugFile)
  79.     {
  80.         va_list    VarArgs;
  81.  
  82.         va_start(VarArgs,String);
  83.  
  84.         if(DebugConsole)
  85.             VFPrintf(DebugConsole,String,(APTR)VarArgs);
  86.  
  87.         if(DebugFile)
  88.             VFPrintf(DebugFile,String,(APTR)VarArgs);
  89.  
  90.         va_end(VarArgs);
  91.     }
  92. }
  93. #endif    /* DONT_DEBUG */
  94.  
  95.     /* ConfigSetup():
  96.      *
  97.      *    Compare the current configuration with the
  98.      *    last backup and reset the serial device, terminal,
  99.      *    etc. if necessary.
  100.      */
  101.  
  102. VOID
  103. ConfigSetup()
  104. {
  105.     if(strcmp(PrivateConfig . MacroFile,Config . MacroFile))
  106.     {
  107.         if(!LoadMacros(Config . MacroFile,MacroKeys))
  108.         {
  109.             SHORT i,j;
  110.  
  111.             for(j = 0 ; j < 4 ; j++)
  112.             {
  113.                 for(i = 0 ; i < 10 ; i++)
  114.                     MacroKeys -> Keys[j][i][0] = 0;
  115.             }
  116.  
  117.             for(i = 0 ; i < 4 ; i++)
  118.                 strcpy(MacroKeys -> Keys[1][i],FunctionKeyCodes[i]);
  119.         }
  120.         else
  121.             strcpy(LastMacros,Config . MacroFile);
  122.     }
  123.  
  124.     if(PrivateConfig . Font != Config . Font)
  125.     {
  126.         if(Config . Font == FONT_TOPAZ)
  127.             SetFont(RPort,Topaz);
  128.         else
  129.         {
  130.             if(IBM)
  131.                 SetFont(RPort,IBM);
  132.         }
  133.     }
  134.  
  135.     if(PrivateConfig . DisplayMode != Config . DisplayMode || PrivateConfig . ColourMode != Config . ColourMode)
  136.         ResetDisplay = TRUE;
  137.  
  138.     if(strcmp(PrivateConfig . Protocol,Config . Protocol))
  139.     {
  140.         strcpy(LastXprLibrary,Config . Protocol);
  141.         ProtocolSetup();
  142.     }
  143.  
  144.     if(memcmp(&PrivateConfig,&Config,58))
  145.     {
  146.         FlushSerial();
  147.  
  148.         DeleteSerial();
  149.  
  150.         if(!CreateSerial())
  151.         {
  152.             MyEasyRequest(Window,"term has a problem:\nFailed to open %s!","Continue",Config . SerialDevice);
  153.  
  154.             DeleteSerial();
  155.         }
  156.     }
  157.  
  158.     if(!ResetDisplay && memcmp(&PrivateConfig . Colours[0],&Config . Colours[0],sizeof(UWORD) * 16))
  159.     {
  160.         SHORT i;
  161.  
  162.         for(i = 0 ; i < 16 ; i++)
  163.             BlinkColours[i] = Config . Colours[i];
  164.  
  165.         LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
  166.  
  167.         switch(Config . ColourMode)
  168.         {
  169.             case COLOUR_EIGHT:    for(i = 0 ; i < 8 ; i++)
  170.                             BlinkColours[i + 8] = BlinkColours[0];
  171.  
  172.                         break;
  173.  
  174.             case COLOUR_SIXTEEN:    break;
  175.  
  176.             case COLOUR_AMIGA:
  177.             default:        BlinkColours[3] = BlinkColours[0];
  178.                         break;
  179.         }
  180.     }
  181.  
  182.     if(Config . EightyColumns)
  183.     {
  184.         if(Config . FontScale == SCALE_HALF)
  185.             LastColumn = 131;
  186.         else
  187.             LastColumn = 79;
  188.  
  189.         LastLine = 23;
  190.  
  191.         BackupRender();
  192.  
  193.         SetAPen(RPort,0);
  194.         RectFill(RPort,0,(LastLine + 1) * 8,Window -> Width - 1,Window -> Height - 1);
  195.  
  196.         BackupRender();
  197.     }
  198.     else
  199.     {
  200.         LastColumn    = (Window -> Width >> 3) - 1;
  201.         LastLine    = (Window -> Height >> 3) - 1;
  202.  
  203.         if(!UseRegion)
  204.             Bottom = LastLine;
  205.     }
  206.  
  207.     if(CursorY > LastLine)
  208.         CursorY = LastLine;
  209.  
  210.     if(PrivateConfig . FontScale == SCALE_HALF && Config . FontScale != SCALE_HALF)
  211.     {
  212.         CursorX >>= 1;
  213.  
  214.         if(Config . EightyColumns)
  215.             LastColumn = 79;
  216.         else
  217.             LastColumn = (Window -> Width >> 3) - 1;
  218.     }
  219.  
  220.     if(PrivateConfig . ColourMode == Config . ColourMode && memcmp(&PrivateConfig . Colours[0],&Config . Colours[0],sizeof(UWORD) * 16))
  221.     {
  222.         switch(Config . ColourMode)
  223.         {
  224.             case COLOUR_EIGHT:    CopyMem(&Config . Colours[0],&ANSIColours[0],16 * sizeof(UWORD));
  225.                         break;
  226.  
  227.             case COLOUR_SIXTEEN:    CopyMem(&Config . Colours[0],&EGAColours[0],16 * sizeof(UWORD));
  228.                         break;
  229.  
  230.             case COLOUR_AMIGA:    CopyMem(&Config . Colours[0],&DefaultColours[0],16 * sizeof(UWORD));
  231.                         break;
  232.  
  233.             case COLOUR_MONO:    CopyMem(&Config . Colours[0],&AtomicColours[0],16 * sizeof(UWORD));
  234.                         break;
  235.         }
  236.     }
  237.  
  238.     SetCursor();
  239. }
  240.  
  241.     /* PubScreenStuff():
  242.      *
  243.      *    This part handles the public screen setup stuff.
  244.      */
  245.  
  246. VOID
  247. PubScreenStuff()
  248. {
  249.         /* Are we to make our screen public? */
  250.  
  251.     if(Config . MakeScreenPublic)
  252.         PubScreenStatus(Screen,NULL);
  253.     else
  254.         PubScreenStatus(Screen,PSNF_PRIVATE);
  255.  
  256.         /* Are we to `shanghai' Workbench windows? */
  257.  
  258.     if(Config . ShanghaiWindows)
  259.     {
  260.         PublicModes |= SHANGHAI;
  261.  
  262.         SetPubScreenModes(PublicModes);
  263.  
  264.             /* Make this the default public screen. */
  265.  
  266.         SetDefaultPubScreen("term");
  267.     }
  268.     else
  269.     {
  270.         PublicModes &= ~SHANGHAI;
  271.  
  272.         if(LockPubScreen(DefaultPubScreen))
  273.         {
  274.             SetDefaultPubScreen(DefaultPubScreen);
  275.  
  276.             UnlockPubScreen(DefaultPubScreen,NULL);
  277.         }
  278.         else
  279.             SetDefaultPubScreen(NULL);
  280.  
  281.         SetPubScreenModes(PublicModes);
  282.     }
  283. }
  284.  
  285.     /* DeleteDisplay():
  286.      *
  287.      *    Free all resources associated with the terminal
  288.      *    display (tasks, interrupts, screen, window, etc.).
  289.      */
  290.  
  291. BYTE
  292. DeleteDisplay()
  293. {
  294.     DeleteRaster();
  295.  
  296.     if(Screen)
  297.     {
  298.         struct List        *PubScreenList;
  299.         struct PubScreenNode    *ScreenNode;
  300.  
  301.         PubScreenList = LockPubScreenList();
  302.  
  303.         for(ScreenNode = (struct PubScreenNode *)PubScreenList -> lh_Head ; ScreenNode -> psn_Node . ln_Succ ; ScreenNode = (struct PubScreenNode *)ScreenNode -> psn_Node . ln_Succ)
  304.         {
  305.             if(ScreenNode -> psn_Screen == Screen)
  306.                 break;
  307.         }
  308.  
  309.         if(ScreenNode)
  310.         {
  311.             if(ScreenNode -> psn_VisitorCount)
  312.             {
  313.                 UnlockPubScreenList();
  314.  
  315.                 return(FALSE);
  316.             }
  317.             else
  318.             {
  319.                 Forbid();
  320.  
  321.                 UnlockPubScreenList();
  322.  
  323.                 PubScreenStatus(Screen,PSNF_PRIVATE);
  324.  
  325.                 Permit();
  326.             }
  327.         }
  328.         else
  329.             UnlockPubScreenList();
  330.     }
  331.  
  332.     if(StatusTask)
  333.     {
  334.         Signal(StatusTask,SIGBREAKF_CTRL_C);
  335.  
  336.         Wait(SIGBREAKF_CTRL_C);
  337.     }
  338.  
  339.     DeleteScale();
  340.  
  341.     if(Screen)
  342.         ScreenToBack(Screen);
  343.  
  344.     if(StatusWindow)
  345.     {
  346.         ClearMenuStrip(StatusWindow);
  347.         CloseWindowSafely(StatusWindow);
  348.  
  349.         StatusWindow = NULL;
  350.     }
  351.  
  352.     if(Window)
  353.     {
  354.         ClearMenuStrip(Window);
  355.  
  356.         ThisProcess -> pr_WindowPtr = OldWindowPtr;
  357.  
  358.         PopWindow();
  359.  
  360.         if(TermPort)
  361.             TermPort -> TopWindow = NULL;
  362.  
  363.         CloseWindow(Window);
  364.  
  365.         Window = NULL;
  366.     }
  367.  
  368.     if(Menu)
  369.     {
  370.         FreeMenus(Menu);
  371.  
  372.         Menu = NULL;
  373.     }
  374.  
  375.     if(VisualInfo)
  376.     {
  377.         FreeVisualInfo(VisualInfo);
  378.  
  379.         VisualInfo = NULL;
  380.     }
  381.  
  382.     DeletePacketWindow();
  383.  
  384.     if(Screen)
  385.     {
  386.         CloseScreen(Screen);
  387.  
  388.         Screen = NULL;
  389.     }
  390.  
  391.     return(TRUE);
  392. }
  393.  
  394.     /* CreateDisplay(BYTE FirstSetup):
  395.      *
  396.      *    Open the display and allocate associated data.
  397.      */
  398.  
  399. UBYTE *
  400. CreateDisplay(BYTE FirstSetup)
  401. {
  402.     UWORD         Dummy = ~0,Count = 0,i;
  403.     LONG         ErrorCode;
  404.     ULONG         TagArray[9];
  405.     struct MenuItem    *SomeItem;
  406.  
  407.         /* We'll configure the screen parameters at
  408.          * run time, at first we'll set up the screen
  409.          * depth.
  410.          */
  411.  
  412.     TagArray[Count++] = SA_Depth;
  413.  
  414.         /* Now set up the approriate colour mode. */
  415.  
  416.     switch(Config . ColourMode)
  417.     {
  418.         case COLOUR_EIGHT:    TagArray[Count++] = 4;
  419.  
  420.                     TagArray[Count++] = SA_DetailPen;
  421.                     TagArray[Count++] = 0;
  422.  
  423.                     TagArray[Count++] = SA_Pens;
  424.                     TagArray[Count++] = (LONG)&ANSIPens;
  425.  
  426.                     TagArray[Count++] = SA_BlockPen;
  427.                     TagArray[Count++] = 4;
  428.  
  429.                     CommandExtend . Pens[0]        = ANSIPens[1];
  430.                     CommandExtend . Pens[1]        = ANSIPens[0];
  431.  
  432.                     CommandExtend . ActivePens[0]    = ANSIPens[1];
  433.                     CommandExtend . ActivePens[1]    = ANSIPens[3];
  434.  
  435.                     break;
  436.  
  437.         case COLOUR_SIXTEEN:    TagArray[Count++] = 4;
  438.  
  439.                     TagArray[Count++] = SA_DetailPen;
  440.                     TagArray[Count++] = 0;
  441.  
  442.                     TagArray[Count++] = SA_Pens;
  443.                     TagArray[Count++] = (LONG)&EGAPens;
  444.  
  445.                     TagArray[Count++] = SA_BlockPen;
  446.                     TagArray[Count++] = 8;
  447.  
  448.                     CommandExtend . Pens[0]        = EGAPens[1];
  449.                     CommandExtend . Pens[1]        = EGAPens[0];
  450.  
  451.                     CommandExtend . ActivePens[0]    = EGAPens[1];
  452.                     CommandExtend . ActivePens[1]    = EGAPens[3];
  453.  
  454.                     break;
  455.  
  456.         case COLOUR_MONO:    TagArray[Count++] = 1;
  457.  
  458.                     TagArray[Count++] = SA_Pens;
  459.                     TagArray[Count++] = (LONG)&Dummy;
  460.  
  461.                     CommandExtend . Pens[0]        = 1;
  462.                     CommandExtend . Pens[1]        = 0;
  463.  
  464.                     CommandExtend . ActivePens[0]    = 1;
  465.                     CommandExtend . ActivePens[1]    = 0;
  466.  
  467.                     break;
  468.  
  469.         case COLOUR_AMIGA:    TagArray[Count++] = 2;
  470.  
  471.                     TagArray[Count++] = SA_Pens;
  472.                     TagArray[Count++] = (LONG)&Dummy;
  473.  
  474.                     CommandExtend . Pens[0]        = 1;
  475.                     CommandExtend . Pens[1]        = 0;
  476.  
  477.                     CommandExtend . ActivePens[0]    = 1;
  478.                     CommandExtend . ActivePens[1]    = 2;
  479.  
  480.                     break;
  481.     }
  482.  
  483.         /* Terminate the tag array. */
  484.  
  485.     TagArray[Count] = TAG_END;
  486.  
  487.         /* Open the screen with the given requirements. */
  488.  
  489. OpenS:    SPrintf(ScreenTitle,"%s (%s) ARexx ID/Screen ID = \"%s\"",TermName,TermDate,TermIDString);
  490.  
  491.     if(!(Screen = (struct Screen *)OpenScreenTags(NULL,
  492.         SA_Title,    ScreenTitle,
  493.         SA_Overscan,    OSCAN_TEXT,
  494.         SA_DisplayID,    Config . DisplayMode,
  495.         SA_Font,    &DefaultFont,
  496.         SA_Behind,    TRUE,
  497.         SA_AutoScroll,    TRUE,
  498.         SA_PubName,    TermIDString,
  499.         SA_ErrorCode,    &ErrorCode,
  500.         TAG_MORE,    &TagArray[0],
  501.     TAG_END)))
  502.     {
  503.             /* We've got an error. */
  504.  
  505.         switch(ErrorCode)
  506.         {
  507.                 /* Can't open screen with these display
  508.                  * modes.
  509.                  */
  510.  
  511.             case OSERR_NOMONITOR:
  512.             case OSERR_NOCHIPS:
  513.             case OSERR_UNKNOWNMODE:        if(Config . DisplayMode & LACE)
  514.                                 Config . DisplayMode = HIRESLACE_KEY;
  515.                             else
  516.                                 Config . DisplayMode = HIRES_KEY;
  517.  
  518.                             goto OpenS;
  519.  
  520.             case OSERR_PUBNOTUNIQUE:    return("Screen ID already in use");
  521.  
  522.                 /* Some different error, probably out of
  523.                  * memory.
  524.                  */
  525.  
  526.             default:            return("Failed to open screen");
  527.         }
  528.     }
  529.  
  530.         /* Set up scaling data (bitmaps & rastports). */
  531.  
  532.     if(!CreateScale())
  533.         return("Failed to create font scaling info");
  534.  
  535.         /* Obtain visual info (whatever that may be). */
  536.  
  537.     if(!(VisualInfo = GetVisualInfo(Screen,TAG_DONE)))
  538.         return("Failed to obtain visual info");
  539.  
  540.     VPort = &Screen -> ViewPort;
  541.  
  542.         /* Fill the `default' colour with current values. */
  543.  
  544.     if(Initializing)
  545.     {
  546.         for(i = 0 ; i < 16 ; i++)
  547.             DefaultColours[i] = GetRGB4(VPort -> ColorMap,i);
  548.  
  549.         Initializing = FALSE;
  550.     }
  551.  
  552.         /* Load the approriate colours. */
  553.  
  554.     if(LoadColours)
  555.     {
  556.         switch(Config . ColourMode)
  557.         {
  558.             case COLOUR_EIGHT:    CopyMem(&ANSIColours[0],&Config . Colours[0],16 * sizeof(UWORD));
  559.                         break;
  560.  
  561.             case COLOUR_SIXTEEN:    CopyMem(&EGAColours[0],&Config . Colours[0],16 * sizeof(UWORD));
  562.                         break;
  563.  
  564.             case COLOUR_AMIGA:    CopyMem(&DefaultColours[0],&Config . Colours[0],16 * sizeof(UWORD));
  565.                         break;
  566.  
  567.             case COLOUR_MONO:    CopyMem(&AtomicColours[0],&Config . Colours[0],16 * sizeof(UWORD));
  568.                         break;
  569.         }
  570.  
  571.         LoadColours = FALSE;
  572.     }
  573.  
  574.         /* Reset the current colours and the blinking equivalents. */
  575.  
  576.     for(i = 0 ; i < 16 ; i++)
  577.         BlinkColours[i] = Config . Colours[i];
  578.  
  579.     LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
  580.  
  581.         /* Fiddle with the blinking colours. */
  582.  
  583.     switch(Config . ColourMode)
  584.     {
  585.         case COLOUR_EIGHT:    for(i = 0 ; i < 8 ; i++)
  586.                         BlinkColours[i + 8] = BlinkColours[0];
  587.  
  588.                     break;
  589.  
  590.         case COLOUR_SIXTEEN:    break;
  591.  
  592.         case COLOUR_AMIGA:
  593.         default:        BlinkColours[3] = BlinkColours[0];
  594.                     break;
  595.     }
  596.  
  597.         /* Open the main window. */
  598.  
  599.     if(!(Window = OpenWindowTags(NULL,
  600.         WA_Top,        Screen -> BarHeight + 2,
  601.         WA_Left,    0,
  602.         WA_Width,    Screen -> Width,
  603.         WA_Height,    Screen -> Height - (Screen -> BarHeight + 2) - (4 + 2 * 8),
  604.         WA_Backdrop,    TRUE,
  605.         WA_Borderless,    TRUE,
  606.         WA_SmartRefresh,TRUE,
  607.         WA_CustomScreen,Screen,
  608.         WA_RMBTrap,    TRUE,
  609.         WA_IDCMP,    IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_GADGETUP | IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS,
  610.     TAG_DONE)))
  611.         return("Failed to open window");
  612.  
  613.         /* Push it on the window stack (should become bottommost
  614.          * entry).
  615.          */
  616.  
  617.     PushWindow(Window);
  618.  
  619.     if(TermPort)
  620.         TermPort -> TopWindow = Window;
  621.  
  622.         /* Open the tiny status window. */
  623.  
  624.     if(!(StatusWindow = OpenWindowTags(NULL,
  625.         WA_Top,        Window -> TopEdge + Window -> Height,
  626.         WA_Left,    0,
  627.         WA_Width,    Screen -> Width,
  628.         WA_Height,    Screen -> Height - (Window -> TopEdge + Window -> Height),
  629.         WA_Backdrop,    TRUE,
  630.         WA_Borderless,    TRUE,
  631.         WA_SmartRefresh,TRUE,
  632.         WA_CustomScreen,Screen,
  633.         WA_RMBTrap,    TRUE,
  634.     TAG_DONE)))
  635.         return("Failed to open status window");
  636.  
  637.         /* Default console setup. */
  638.  
  639.     if(Config . EightyColumns)
  640.     {
  641.         LastColumn    = 79;
  642.         LastLine    = 23;
  643.     }
  644.     else
  645.     {
  646.         LastColumn    = (Window -> Width >> 3) - 1;
  647.         LastLine    = (Window -> Height >> 3) - 1;
  648.     }
  649.  
  650.     CursorX = 0;
  651.     CursorY    = 0;
  652.  
  653.     SetDrMd(Window -> RPort,JAM2);
  654.  
  655.     StatusWindow -> UserPort = Window -> UserPort;
  656.  
  657.     ModifyIDCMP(StatusWindow,Window -> IDCMPFlags);
  658.  
  659.     RPort = Window -> RPort;
  660.  
  661.         /* Redirect AmigaDOS requesters. */
  662.  
  663.     OldWindowPtr = ThisProcess -> pr_WindowPtr;
  664.  
  665.     ThisProcess -> pr_WindowPtr = (APTR)Window;
  666.  
  667.         /* Create the character raster. */
  668.  
  669.     if(!CreateRaster())
  670.         return("Unable to create screen raster");
  671.  
  672.         /* Reset terminal emulation. */
  673.  
  674.     Reset();
  675.  
  676.         /* Set the font. */
  677.  
  678.     if(Config . Font == FONT_IBM && IBM)
  679.         SetFont(RPort,IBM);
  680.     else
  681.         SetFont(RPort,Topaz);
  682.  
  683.         /* Create the menu strip. */
  684.  
  685.     if(!(Menu = CreateMenus(TermMenu,
  686.         GTMN_FrontPen, 0,
  687.     TAG_DONE)))
  688.         return("Failed to create menus");
  689.  
  690.         /* Do the menu layout. */
  691.  
  692.     if(!LayoutMenus(Menu,VisualInfo,
  693.         GTMN_TextAttr,&DefaultFont,
  694.     TAG_DONE))
  695.         return("Failed to layout menus");
  696.  
  697.         /* Disable the `Execute ARexx Command' menu item if
  698.          * the rexx server is not available.
  699.          */
  700.  
  701.     if(!RexxSysBase)
  702.     {
  703.         struct MenuItem *SomeItem;
  704.  
  705.         if(SomeItem = FindThisItem(MEN_REXXCOMMAND))
  706.             SomeItem -> Flags &= ~ITEMENABLED;
  707.     }
  708.  
  709.         /* Add a tick if file capture is active. */
  710.  
  711.     if(FileCapture)
  712.     {
  713.         if(SomeItem = FindThisItem(MEN_CAPTUREDISK))
  714.             SomeItem -> Flags |= CHECKED;
  715.     }
  716.  
  717.         /* Add a tick if printer capture is active. */
  718.  
  719.     if(PrinterCapture)
  720.     {
  721.         if(SomeItem = FindThisItem(MEN_CAPTUREPRINTER))
  722.             SomeItem -> Flags |= CHECKED;
  723.     }
  724.  
  725.         /* Add the menu to the windows. */
  726.  
  727.     SetMenuStrip(Window,Menu);
  728.     SetMenuStrip(StatusWindow,Menu);
  729.  
  730.         /* Enable the menu. */
  731.  
  732.     Window -> Flags        &= ~WFLG_RMBTRAP;
  733.     StatusWindow -> Flags    &= ~WFLG_RMBTRAP;
  734.  
  735.         /* Set up the status window, draw a border. */
  736.  
  737.     DrawBevelBox(StatusWindow -> RPort,0,0,StatusWindow -> Width,StatusWindow -> Height,
  738.         GT_VisualInfo,VisualInfo,
  739.     TAG_DONE);
  740.  
  741.         /* Render the information. */
  742.  
  743.     switch(Config . ColourMode)
  744.     {
  745.         case COLOUR_EIGHT:    SetAPen(StatusWindow -> RPort,4);
  746.                     break;
  747.  
  748.         case COLOUR_SIXTEEN:    SetAPen(StatusWindow -> RPort,8);
  749.                     break;
  750.  
  751.         case COLOUR_AMIGA:
  752.         default:        SetAPen(StatusWindow -> RPort,1);
  753.                     break;
  754.     }
  755.  
  756.     SetBPen(StatusWindow -> RPort,0);
  757.     SetDrMd(StatusWindow -> RPort,JAM2);
  758.  
  759.     Move(StatusWindow -> RPort,(Screen -> Width - (79 << 3)) >> 1,2 + 6 + 0);
  760.     Text(StatusWindow -> RPort,"Status ..:          Protocol :          Baud Rate:          Time ....:",70);
  761.  
  762.     Move(StatusWindow -> RPort,(Screen -> Width - (79 << 3)) >> 1,2 + 6 + 8);
  763.     Text(StatusWindow -> RPort,"Font ....:          Emulation:          Parameters          Online ..:",70);
  764.  
  765.     switch(Config . ColourMode)
  766.     {
  767.         case COLOUR_EIGHT:    SetAPen(StatusWindow -> RPort,6);
  768.                     break;
  769.  
  770.         case COLOUR_SIXTEEN:    SetAPen(StatusWindow -> RPort,7);
  771.                     break;
  772.  
  773.         case COLOUR_AMIGA:    SetAPen(StatusWindow -> RPort,2);
  774.                     break;
  775.  
  776.         case COLOUR_MONO:    SetAPen(StatusWindow -> RPort,1);
  777.                     break;
  778.     }
  779.  
  780.         /* Create the status server. */
  781.  
  782.     if(!(StatusTask = (struct Task *)CreateTask("term Status Task",5,StatusServer,4096)))
  783.         return("Unable to create status task");
  784.  
  785.         /* Wait for ringback signal. */
  786.  
  787.     Wait(SIGBREAKF_CTRL_C);
  788.  
  789.         /* Status server has `died'. */
  790.  
  791.     if(!StatusTask)
  792.         return("Unable to create status task");
  793.  
  794.         /* Obtain the default public screen name just in case
  795.          * we'll need it later.
  796.          */
  797.  
  798.     GetDefaultPubScreen(DefaultPubScreen);
  799.  
  800.     return(NULL);
  801. }
  802.  
  803.     /* CloseAll():
  804.      *
  805.      *    Free all resources and leave the program.
  806.      */
  807.  
  808. VOID
  809. CloseAll()
  810. {
  811.     if(IntuitionBase && Window && StatusWindow)
  812.         BlockWindows();
  813.  
  814.     if(RexxProcess)
  815.     {
  816.         Signal(RexxProcess,SIGBREAKF_CTRL_C);
  817.  
  818.         Wait(SIGBREAKF_CTRL_C);
  819.     }
  820.  
  821.     if(TermRexxPort)
  822.     {
  823.         if(RexxSysBase)
  824.         {
  825.             struct RexxMsg *RexxMsg;
  826.  
  827.             while(RexxMsg = (struct RexxMsg *)GetMsg(TermRexxPort))
  828.                 ReplyRexxCommand(RexxMsg,RC_ERROR,0,NULL);
  829.         }
  830.  
  831.         DeleteMsgPort(TermRexxPort);
  832.     }
  833.  
  834.     if(XprIO && XProtocolBase)
  835.         XProtocolCleanup(XprIO);
  836.  
  837.     if(XProtocolBase)
  838.         CloseLibrary(XProtocolBase);
  839.  
  840.     if(XprIO)
  841.         FreeMem(XprIO,sizeof(struct XPR_IO));
  842.  
  843.     if(FileAnchor)
  844.         FreeMem(FileAnchor,sizeof(struct AnchorPath));
  845.  
  846.     if(Phonebook && PhoneSize)
  847.         DeletePhonebook(Phonebook,PhoneSize,TRUE);
  848.  
  849.     if(MacroKeys)
  850.         FreeVec(MacroKeys);
  851.  
  852.     ClearBuffer();
  853.  
  854.     DeleteSpeech();
  855.  
  856.     if(BufferLines)
  857.         FreeVec(BufferLines);
  858.  
  859.     if(BufferSemaphore)
  860.         FreeMem(BufferSemaphore,sizeof(struct SignalSemaphore));
  861.  
  862.     ClearDownloadObjects();
  863.  
  864.     if(DownloadSemaphore)
  865.         FreeMem(DownloadSemaphore,sizeof(struct SignalSemaphore));
  866.  
  867.     FreeSubList();
  868.  
  869.     if(FileCapture)
  870.     {
  871.         Close(FileCapture);
  872.  
  873.         if(!GetFileSize(CaptureName))
  874.             DeleteFile(CaptureName);
  875.     }
  876.  
  877.     if(PrinterCapture)
  878.         Close(PrinterCapture);
  879.  
  880.     DeleteDisplay();
  881.  
  882.     if(TimeRequest)
  883.     {
  884.         if(TimeRequest -> tr_node . io_Device)
  885.             CloseDevice(TimeRequest);
  886.  
  887.         if(TimeRequest -> tr_node . io_Message . mn_ReplyPort)
  888.             DeleteMsgPort(TimeRequest -> tr_node . io_Message . mn_ReplyPort);
  889.  
  890.         DeleteIORequest(TimeRequest);
  891.     }
  892.  
  893.     DeleteBeep();
  894.  
  895.     FlushSerial();
  896.  
  897.     DeleteSerial();
  898.  
  899.     ShutdownCx();
  900.  
  901.     if(TermPort)
  902.     {
  903.         if(TermID != -1)
  904.         {
  905.             ObtainSemaphore(&TermPort -> OpenSemaphore);
  906.  
  907.             TermPort -> OpenCount--;
  908.  
  909.             if(TermPort -> OpenCount <= 0 && !TermPort -> HoldIt)
  910.             {
  911.                 RemPort(&TermPort -> ExecNode);
  912.  
  913.                 ReleaseSemaphore(&TermPort -> OpenSemaphore);
  914.  
  915.                 FreeVec(TermPort);
  916.             }
  917.             else
  918.                 ReleaseSemaphore(&TermPort -> OpenSemaphore);
  919.         }
  920.     }
  921.  
  922.     if(LayersBase)
  923.         CloseLibrary(LayersBase);
  924.  
  925.     if(CxBase)
  926.         CloseLibrary(CxBase);
  927.  
  928.     if(IFFParseBase)
  929.         CloseLibrary(IFFParseBase);
  930.  
  931.     if(AslBase)
  932.         CloseLibrary(AslBase);
  933.  
  934.     if(DiskfontBase)
  935.         CloseLibrary(DiskfontBase);
  936.  
  937.     if(FakeInputEvent)
  938.         FreeMem(FakeInputEvent,sizeof(struct InputEvent));
  939.  
  940.     if(ConsoleDevice)
  941.         CloseDevice(ConsoleRequest);
  942.  
  943.     if(ConsoleRequest)
  944.         FreeMem(ConsoleRequest,sizeof(struct IOStdReq));
  945.  
  946.     if(IBM)
  947.         CloseFont(IBM);
  948.  
  949.     if(GFX)
  950.         CloseFont(GFX);
  951.  
  952.     if(Topaz)
  953.         CloseFont(Topaz);
  954.  
  955.     if(RexxSysBase)
  956.         CloseLibrary(RexxSysBase);
  957.  
  958.     if(GadToolsBase)
  959.         CloseLibrary(GadToolsBase);
  960.  
  961.     if(GfxBase)
  962.         CloseLibrary(GfxBase);
  963.  
  964.     if(IntuitionBase)
  965.         CloseLibrary(IntuitionBase);
  966.  
  967. #ifndef DONT_DEBUG
  968.     DExit();
  969. #endif     /* DONT_DEBUG */
  970.  
  971.     if(RemoteCurrentDir)
  972.         UnLock(RemoteCurrentDir);
  973.  
  974.     if(DOSBase)
  975.         CloseLibrary(DOSBase);
  976.  
  977.     if(WBenchMsg)
  978.     {
  979.         Forbid();
  980.  
  981.         ReplyMsg((struct Message *)WBenchMsg);
  982.     }
  983. }
  984.  
  985.     /* OpenAll():
  986.      *
  987.      *    Open all required resources or return an error message
  988.      *    if anything went wrong.
  989.      */
  990.  
  991. UBYTE *
  992. OpenAll()
  993. {
  994.     UBYTE         PathBuffer[256];
  995.     struct MsgPort    *IOPort;
  996.     SHORT         i;
  997.  
  998. #ifndef DONT_DEBUG
  999.     DInit();
  1000. #endif    /* DONT_DEBUG */
  1001.  
  1002.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0)))
  1003.         return("Failed to open intuition.library");
  1004.  
  1005.     if((SysBase -> SoftVer < 74 && SysBase -> LibNode . lib_Version == 37) || SysBase -> LibNode . lib_Version < 37)
  1006.     {
  1007.         if(!MyEasyRequest(NULL,"This   nifty  little  program  requires  Kickstart\nversion 37.74 or higher to work properly.  You are\ncurrently  using Kickstart version %ld.%ld, do you\nreally wish to continue???",
  1008.             "Proceed with fingers crossed|Back out backwards!",SysBase -> LibNode . lib_Version,SysBase -> SoftVer))
  1009.                 return("");
  1010.     }
  1011.  
  1012.     PublicModes = SetPubScreenModes(0);
  1013.  
  1014.     SetPubScreenModes(PublicModes);
  1015.  
  1016.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0)))
  1017.         return("Failed to open graphics.library");
  1018.  
  1019.     if(!(GadToolsBase = OpenLibrary("gadtools.library",0)))
  1020.         return("Failed to open gadtools.library");
  1021.  
  1022.     if(!(AslBase = OpenLibrary("asl.library",0)))
  1023.         return("Failed to open asl.library");
  1024.  
  1025.     if(!(IFFParseBase = OpenLibrary("iffparse.library",0)))
  1026.         return("Failed to open iffparse.library");
  1027.  
  1028.     if(!(CxBase = OpenLibrary("commodities.library",0)))
  1029.         return("Failed to open commodities.library");
  1030.  
  1031.     if(!(LayersBase = OpenLibrary("layers.library",0)))
  1032.         return("Failed to open layers.library");
  1033.  
  1034.     if(!(Topaz = (struct TextFont *)OpenFont(&DefaultFont)))
  1035.         return("Failed to open default font");
  1036.  
  1037.     if(!(ConsoleRequest = (struct IOStdReq *)AllocMem(sizeof(struct IOStdReq),MEMF_PUBLIC|MEMF_CLEAR)))
  1038.         return("Failed to allocate console request");
  1039.  
  1040.     if(OpenDevice("console.device",CONU_LIBRARY,ConsoleRequest,0))
  1041.         return("Failed to open console.device");
  1042.  
  1043.     ConsoleDevice = &ConsoleRequest -> io_Device -> dd_Library;
  1044.  
  1045.     if(!(FakeInputEvent = (struct InputEvent *)AllocMem(sizeof(struct InputEvent),MEMF_PUBLIC|MEMF_CLEAR)))
  1046.         return("Failed to allocate InputEvent");
  1047.  
  1048.     FakeInputEvent -> ie_Class = IECLASS_RAWKEY;
  1049.  
  1050.     if(!(MacroKeys = (struct MacroKeys *)AllocVec(sizeof(struct MacroKeys),MEMF_PUBLIC|MEMF_CLEAR)))
  1051.         return("Failed to allocate MacroKeys");
  1052.  
  1053.     if(DiskfontBase = (struct Library *)OpenLibrary("diskfont.library",0))
  1054.     {
  1055.         if(!(IBM = (struct TextFont *)OpenFont(&IBMFont)))
  1056.             IBM = (struct TextFont *)OpenDiskFont(&IBMFont);
  1057.  
  1058.         if(!(GFX = (struct TextFont *)OpenFont(&GFXFont)))
  1059.             GFX = (struct TextFont *)OpenDiskFont(&GFXFont);
  1060.     }
  1061.  
  1062.         /* Our default empty list (gadtools listviews need this). */
  1063.  
  1064.     NewList(&EmptyList);
  1065.  
  1066.         /* Initialize the data flow parser. */
  1067.  
  1068.     FlowInit();
  1069.  
  1070.         /* Obtain the default environment storage
  1071.          * path.
  1072.          */
  1073.  
  1074.     if(!GetEnvDOS("TERMPATH",PathBuffer))
  1075.     {
  1076.         APTR LastPtr = ThisProcess -> pr_WindowPtr;
  1077.         BPTR FileLock;
  1078.  
  1079.         strcpy(PathBuffer,"ENVARC:term");
  1080.  
  1081.         SetEnvDOS("TERMPATH",PathBuffer);
  1082.  
  1083.         ThisProcess -> pr_WindowPtr = (APTR)-1;
  1084.  
  1085.         if(!(FileLock = Lock(PathBuffer,ACCESS_READ)))
  1086.             FileLock = CreateDir(PathBuffer);
  1087.  
  1088.         if(FileLock)
  1089.             UnLock(FileLock);
  1090.  
  1091.         ThisProcess -> pr_WindowPtr = LastPtr;
  1092.     }
  1093.  
  1094.         /* Create proper path names. */
  1095.  
  1096.     strcpy(LastConfig,PathBuffer);
  1097.  
  1098.     AddPart(LastConfig,"Preferences.term",256);
  1099.  
  1100.     strcpy(DefaultPubScreen,"Workbench");
  1101.  
  1102.         /* Read some more environment variables. */
  1103.  
  1104.     if(!GetEnvDOS("TERMWINDOW",WindowName))
  1105.         strcpy(WindowName,"CON:0/11//100/term Output Window/CLOSE/SCREENTERM");
  1106.  
  1107.     GetEnvDOS("EDITOR",Config . Editor);
  1108.  
  1109.         /* Look for the default configuration file. */
  1110.  
  1111.     if(!ReadIFFData(LastConfig,&Config,sizeof(struct Configuration),'PREF'))
  1112.     {
  1113.         SetPrefToDefaults(&Config,PathBuffer);
  1114.  
  1115.         Initializing = TRUE;
  1116.  
  1117.         LoadColours = TRUE;
  1118.     }
  1119.     else
  1120.     {
  1121.         switch(Config . ColourMode)
  1122.         {
  1123.             case COLOUR_EIGHT:    CopyMem(&Config . Colours[0],&ANSIColours[0],16 * sizeof(UWORD));
  1124.                         break;
  1125.  
  1126.             case COLOUR_SIXTEEN:    CopyMem(&Config . Colours[0],&EGAColours[0],16 * sizeof(UWORD));
  1127.                         break;
  1128.  
  1129.             case COLOUR_AMIGA:    CopyMem(&Config . Colours[0],&DefaultColours[0],16 * sizeof(UWORD));
  1130.                         break;
  1131.  
  1132.             case COLOUR_MONO:    CopyMem(&Config . Colours[0],&AtomicColours[0],16 * sizeof(UWORD));
  1133.                         break;
  1134.         }
  1135.  
  1136.         if(Config . ColourMode == COLOUR_AMIGA)
  1137.             Initializing = FALSE;
  1138.         else
  1139.             Initializing = TRUE;
  1140.     }
  1141.  
  1142.     strcpy(LastPhone,Config . DefaultStorage);
  1143.     strcpy(LastMacros,Config . DefaultStorage);
  1144.     strcpy(LastKeys,Config . DefaultStorage);
  1145.     strcpy(LastSpeech,Config . DefaultStorage);
  1146.  
  1147.     AddPart(LastPhone,"Phonebook.term",256);
  1148.     AddPart(LastMacros,"Macros.term",256);
  1149.     AddPart(LastKeys,"Hotkeys.term",256);
  1150.     AddPart(LastSpeech,"Speech.term",256);
  1151.  
  1152.         /* Load the keyboard macros. */
  1153.  
  1154.     if(!LoadMacros(LastMacros,MacroKeys))
  1155.     {
  1156.         for(i = 0 ; i < 4 ; i++)
  1157.             strcpy(MacroKeys -> Keys[1][i],FunctionKeyCodes[i]);
  1158.     }
  1159.  
  1160.     LoadPhonebook(LastPhone);
  1161.  
  1162.     if(!ReadIFFData(LastSpeech,&SpeechConfig,sizeof(struct SpeechConfig),'SPEK'))
  1163.     {
  1164.         SpeechConfig . Rate        = DEFRATE;
  1165.         SpeechConfig . Pitch        = DEFPITCH;
  1166.         SpeechConfig . Frequency    = DEFFREQ;
  1167.         SpeechConfig . Volume        = DEFVOL;
  1168.         SpeechConfig . Sex        = DEFSEX;
  1169.         SpeechConfig . Enabled        = FALSE;
  1170.     }
  1171.  
  1172.     if(!ReadIFFData(LastKeys,&Hotkeys,sizeof(struct Hotkeys),'HOTK'))
  1173.     {
  1174.         strcpy(Hotkeys . termScreenToFront,"lshift rshift return");
  1175.         strcpy(Hotkeys . BufferScreenToFront,"control rshift return");
  1176.         strcpy(Hotkeys . SkipDialEntry,"control lshift rshift return");
  1177.  
  1178.         Hotkeys . CommodityPriority = 0;
  1179.         Hotkeys . HotkeysEnabled = TRUE;
  1180.     }
  1181.  
  1182.     if(!CreateSerial())
  1183.     {
  1184.         MyEasyRequest(NULL,"term has a problem:\nFailed to open %s!","Continue",Config . SerialDevice);
  1185.  
  1186.         DeleteSerial();
  1187.     }
  1188.  
  1189.         /* Load alternative beep sound if desired. */
  1190.  
  1191.     if(Config . BeepSound[0])
  1192.         OpenSound(Config . BeepSound);
  1193.  
  1194.     if(!CreateBeep())
  1195.         return("Failed to open audio.device");
  1196.  
  1197.     if(!(IOPort = (struct MsgPort *)CreateMsgPort()))
  1198.         return("Failed to create msgport");
  1199.  
  1200.     if(!(IOPort = (struct MsgPort *)CreateMsgPort()))
  1201.         return("Failed to create msgport");
  1202.  
  1203.     if(!(TimeRequest = (struct timerequest *)CreateIORequest(IOPort,sizeof(struct timerequest))))
  1204.     {
  1205.         DeleteMsgPort(IOPort);
  1206.         return("Failed to create iorequest");
  1207.     }
  1208.  
  1209.     if(OpenDevice("timer.device",UNIT_VBLANK,TimeRequest,0))
  1210.         return("Failed to open timer.device");
  1211.  
  1212.     TimerBase = (struct Device *)TimeRequest -> tr_node . io_Device;
  1213.  
  1214.         /* Add the global term port. */
  1215.  
  1216.     if(!TermPort)
  1217.     {
  1218.         if(!(TermPort = (struct TermPort *)AllocVec(sizeof(struct TermPort),MEMF_PUBLIC|MEMF_CLEAR)))
  1219.             return("Failed to create global port");
  1220.  
  1221.         NewList(&TermPort -> ExecNode . mp_MsgList);
  1222.  
  1223.         InitSemaphore(&TermPort -> OpenSemaphore);
  1224.  
  1225.         TermPort -> ExecNode . mp_Flags            = PA_IGNORE;
  1226.         TermPort -> ExecNode . mp_Node . ln_Name    = "term Port";
  1227.  
  1228.         AddPort(&TermPort -> ExecNode);
  1229.     }
  1230.  
  1231.         /* Keep another term task from removing the port. */
  1232.  
  1233.     TermPort -> HoldIt = TRUE;
  1234.  
  1235.         /* Install a new term process. */
  1236.  
  1237.     ObtainSemaphore(&TermPort -> OpenSemaphore);
  1238.  
  1239.     TermPort -> OpenCount++;
  1240.  
  1241.     TermPort -> HoldIt = FALSE;
  1242.  
  1243.     TermID = TermPort -> ID++;
  1244.  
  1245.     ReleaseSemaphore(&TermPort -> OpenSemaphore);
  1246.  
  1247.         /* Set up the ID string. */
  1248.  
  1249.     if(TermID)
  1250.         SPrintf(TermIDString,"TERM%ld",TermID);
  1251.     else
  1252.         strcpy(TermIDString,"TERM");
  1253.  
  1254.         /* Install the hotkey handler. */
  1255.  
  1256.     SetupCx();
  1257.  
  1258.         /* Create the speech data. */
  1259.  
  1260.     CreateSpeech();
  1261.  
  1262.         /* Allocate the first few lines for the display buffer. */
  1263.  
  1264.     if(!(BufferLines = (UBYTE **)AllocVec(MaxLines * sizeof(UBYTE *),MEMF_PUBLIC|MEMF_CLEAR)))
  1265.         return("Failed to allocate view buffer");
  1266.  
  1267.     if(!(XprIO = (struct XPR_IO *)AllocMem(sizeof(struct XPR_IO),MEMF_PUBLIC|MEMF_CLEAR)))
  1268.         return("Failed to create protocol buffer");
  1269.  
  1270.     if(!(FileAnchor = (struct AnchorPath *)AllocMem(sizeof(struct AnchorPath),MEMF_PUBLIC|MEMF_CLEAR)))
  1271.         return("Failed to create anchor path");
  1272.  
  1273.         /* Create the download list access semaphore. */
  1274.  
  1275.     if(!(DownloadSemaphore = (struct SignalSemaphore *)AllocMem(sizeof(struct SignalSemaphore),MEMF_PUBLIC|MEMF_CLEAR)))
  1276.         return("Failed to allocate semaphore");
  1277.  
  1278.     InitSemaphore(DownloadSemaphore);
  1279.  
  1280.     NewList(&SequenceList);
  1281.     NewList(&PacketHistoryList);
  1282.     NewList(&DownloadList);
  1283.  
  1284.         /* Create the buffer access semaphore. */
  1285.  
  1286.     if(!(BufferSemaphore = (struct SignalSemaphore *)AllocMem(sizeof(struct SignalSemaphore),MEMF_PUBLIC|MEMF_CLEAR)))
  1287.         return("Failed to allocate semaphore");
  1288.  
  1289.     InitSemaphore(BufferSemaphore);
  1290.  
  1291.     strcpy(LastXprLibrary,Config . Protocol);
  1292.  
  1293.     ProtocolSetup();
  1294.  
  1295.     if(!(TermRexxPort = (struct MsgPort *)CreateMsgPort()))
  1296.         return("Failed to create msgport");
  1297.  
  1298.         /* If rexxsyslib.library opens cleanly it's time for
  1299.          * us to create the background term Rexx server.
  1300.          */
  1301.  
  1302.     if(RexxSysBase = (struct RxsLib *)OpenLibrary(RXSNAME,0))
  1303.     {
  1304.             /* Create a background process handling the
  1305.              * rexx messages asynchronously.
  1306.              */
  1307.  
  1308.         if(RexxProcess = (struct Process *)CreateNewProcTags(
  1309.             NP_Entry,    RexxServer,
  1310.             NP_Name,    "term Rexx Process",
  1311.             NP_Priority,    5,
  1312.             NP_StackSize,    8192,
  1313.             NP_WindowPtr,    -1,
  1314.         TAG_END))
  1315.         {
  1316.             Wait(SIGBREAKF_CTRL_C);
  1317.  
  1318.             if(!RexxProcess)
  1319.                 return("Unable to create rexx process");
  1320.         }
  1321.     }
  1322.  
  1323.     BinaryTransfer    = TRUE;
  1324.  
  1325.     Status        = STATUS_READY;
  1326.     Online        = FALSE;
  1327.  
  1328.     InSequence    = FALSE;
  1329.     Quiet        = FALSE;
  1330.  
  1331.     memset(&SpecialMap[0],-1,256);
  1332.  
  1333.     for(i = 0 ; i < SPECIALKEYS ; i++)
  1334.         SpecialMap[SpecialKeys[i] . Key] = i;
  1335.  
  1336.     CommandExtend . Font = Topaz;
  1337.  
  1338.     InitHook(&CommandHook,CommandKey);
  1339.  
  1340.         /* Create the whole display. */
  1341.  
  1342.     return(CreateDisplay(TRUE));
  1343. }
  1344.